All Questions
17 questions
0votes
3answers
434views
Would you test this piece of configuration code? How do I determine which code is worth testing?
We have a piece of code that decorates an interface to transparently add retry logic. Inversion of Control configuration service.AddOurRestApiClient() .AddResilienceHandler("Retry", ...
1vote
2answers
342views
Best Practice: Unit test coverage vs. in-method sanity checks [duplicate]
I have a code-coverage requirement of of a certain percentage, and face the following tradeoff: Should I sacrifice in-method sanity checks and error handling for ease of (unit-) testability? Lets ...
-1votes
3answers
1kviews
Should methods with business logic be made private? [duplicate]
So I am writing a project using Spring Boot. All of my logic resides in @Service classes. I have separated each service class based on entity. For example - If I have two independent entities A and B, ...
6votes
3answers
7kviews
What is recommended way to create test data for unit test cases?
I am new to TDD/unit testing. I am going to write a complex scheduling algorithm in Java. As this module is a core part of our application and there are number of scenarios in it, I want to write ...
5votes
3answers
2kviews
Is this unit test too tightly coupled to implementation?
I believe the existence of this unit test is justified. However, to me, this unit test seems very coupled to the method implementation, though I'm not sure it can be improved upon. class ItemManager {...
-3votes
3answers
316views
What is the most elemental workflow for TDD?
Gradle is such an interesting build tool that it prompted me to look at Spock and JUnit -- which I've never done before. What is the basic workflow with TDD? My approach has been to do frequent ...
2votes
2answers
3kviews
Ways of creating expected object for assert
Recently, I started to use TDD. It's really cool and fun but creating expected object for assertEquals is very boring and tedious. At the moment I see only two way for that: Straightforward Creating ...
11votes
1answer
15kviews
Testing private methods as protected
I was reading this answer about testing private methods and it mentioned several possibilities: extract methods as public to another class make them public separate the env of test and production so ...
10votes
3answers
11kviews
Advantage/Disadvantage of having all variables declared in a JUnit Test
I've been writing some unit tests for some new code at work, and sent it off for a code review. One of my co-workers made a comment about why I was putting variables that are used in a number of those ...
22votes
4answers
3kviews
How can I use unit tests and TDD to test an app that relies mostly on database CRUD operations?
At work, one of my projects is mostly about taking data passed in from an external client and persisting it in a database. It's a Java enterprise app using JPA and most of our logic revolves around ...
1vote
1answer
214views
Test Doubles : Do they go in "source packages" or "test packages"?
I've got a couple of data access objects (DefaultPersonServices.class, DefaultAddressServices.class) which is responsible for various CRUD operations in a database. A few different classes use these ...
1vote
1answer
5kviews
Is it worth writing a unit test for a DTO with the most basic getter/setters? [duplicate]
The advantage is it protects your DTO against future "enhancements" ?
21votes
1answer
4kviews
Is there a modern replacement for a mutation testing tool like Jester for Java?
“Why just think your tests are good when you can know for sure? Sometimes Jester tells me my tests are airtight, but sometimes the changes it finds come as a bolt out of the blue. Highly ...
3votes
2answers
255views
Do I need to learn python first to understand the part 2 of the book Test Driven development?
It seems like Python is used as a coding language for part 2 of Kent Beck's book Test Driven Development. I have read the first part of that book and started appreciating the value of TDD . First part ...
-2votes
2answers
873views
How can I test database access methods in Java? [closed]
I want to write a test for a method that accesses a database such as following. public class MyClass{ public String getAddress(Int id){ String query = "Select * from Address where id="+...